/*
 * Copyright (c) 2008 Benoit Bouchez, Nicolas Giard
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.noocodecommit.wicket.stuff.jquery.plugin.ui.sortable;

import com.noocodecommit.wicket.stuff.jquery.plugin.JQPluginOptions;

/**
 * JQSortable Option set
 * 
 * @author Benoit Bouchez
 * 
 */
public class JQSortableOptions extends JQPluginOptions implements Cloneable
{

	/** x axis value */
	public static final String AXIS_X = "x";
	/** y axis value */
	public static final String AXIS_Y = "y";
	/** guess tolerance value */
	public static final String TOLERANCE_GUESS = "guess";
	/** intersect tolerance value */
	public static final String TOLERANCE_INTERSECT = "intersect";
	/** tolerance tolerance value */
	public static final String TOLERANCE_TOLERANCE = "tolerance";
	/** pointer tolerance value */
	public static final String TOLERANCE_POINTER = "pointer";

	private String items = "> *";
	private String connectWith;
	private String handle;
	private String helper;
	private String containment;
	private String axis;
	private String cancel = ":input, button";
	private String cursor;
	private String placeholder;
	private String tolerance = TOLERANCE_GUESS;
	private boolean revert = true;
	private boolean scroll = true;
	private boolean dropOnEmpty = true;
	private boolean forcePlaceholderSize = false;
	private int scrollSpeed = 20;
	private int scrollSensitivity = 20;
	private int zIndex;
	private float opacity;
	private int delay = 0;
	private int distance = 1;

	private String startScript = "";
	private String stopScript = "";
	private String beforeStopScript = "";
	private String updateScript = "";
	private String sortScript = "";
	private String changeScript = "";
	private String receiveScript = ""; // Function that gets called when a connected sortable list has received an item from another list.
	private String removeScript = "";
	private String overScript = "";
	private String outScript = "";
	private String activateScript = "";
	private String deactivateScript = "";

	/**
	 * Constructor
	 */
	public JQSortableOptions()
	{
		super();
		this.setDefaultHeader("sortable");
	}

	/**
	 * Gets the item value
	 * 
	 * @return the item value
	 */
	public String getItems()
	{
		return items;
	}

	/**
	 * Sets the items option value
	 * 
	 * @param items
	 *            sortable items
	 */
	public void setItems(String items)
	{
		this.items = items;
		this.options.put("items", "items:'" + items + "'");
	}

	/**
	 * Gets the connectWith value
	 * 
	 * @return the connectWith value
	 */
	public String getConnectWith()
	{
		return connectWith;
	}

	/**
	 * Sets the connectWith option value
	 * 
	 * @param connectWith
	 *            sortable connectWith
	 */
	public void setConnectWith(String connectWith)
	{
		this.connectWith = connectWith;
		this.options.put("connectWith", "connectWith:[" + connectWith + "]");
	}

	/**
	 * Gets the handle value
	 * 
	 * @return the handle value
	 */
	public String getHandle()
	{
		return handle;
	}

	/**
	 * Sets the handle option value
	 * 
	 * @param handle
	 *            sortable handle
	 */
	public void setHandle(String handle)
	{
		this.handle = handle;
		this.options.put("handle", "handle:'" + handle + "'");
	}

	/**
	 * Gets the helper value
	 * 
	 * @return the helper value
	 */
	public String getHelper()
	{
		return helper;
	}

	/**
	 * Sets the helper option value
	 * 
	 * @param helper
	 *            sortable helper
	 */
	public void setHelper(String helper)
	{
		this.helper = helper;
		this.options.put("helper", "helper:'" + helper + "'");
	}

	/**
	 * Gets the revert value
	 * 
	 * @return the revert value
	 */
	public boolean isRevert()
	{
		return revert;
	}

	/**
	 * Sets the revert option value
	 * 
	 * @param revert
	 *            sortable revert
	 */
	public void setRevert(boolean revert)
	{
		this.revert = revert;
		this.options.put("revert", "revert:" + revert);
	}

	/**
	 * Gets the axis value
	 * 
	 * @return the axis value
	 */
	public String getAxis()
	{
		return axis;
	}

	/**
	 * Sets the axis option value
	 * 
	 * @param axis
	 *            sortable axis
	 */
	public void setAxis(String axis)
	{
		this.axis = axis;
		this.options.put("axis", "axis:'" + axis + "'");
	}

	/**
	 * Gets the scroll value
	 * 
	 * @return the scroll value
	 */
	public boolean isScroll()
	{
		return scroll;
	}

	/**
	 * Sets the scroll option value
	 * 
	 * @param scroll
	 *            sortable scroll
	 */
	public void setScroll(boolean scroll)
	{
		this.scroll = scroll;
		this.options.put("scroll", "scroll:" + scroll);
	}

	/**
	 * Gets the scroll speed value
	 * 
	 * @return the scroll speed value
	 */
	public int getScrollSpeed()
	{
		return scrollSpeed;
	}

	/**
	 * Sets the scroll speed option value
	 * 
	 * @param scrollSpeed
	 *            sortable scroll speed
	 */
	public void setScrollSpeed(int scrollSpeed)
	{
		this.scrollSpeed = scrollSpeed;
		this.options.put("scrollSpeed", "scrollSpeed:" + scrollSpeed);
	}

	/**
	 * Gets the scroll sensitivity value
	 * 
	 * @return the scroll sensitivity value
	 */
	public int getScrollSensitivity()
	{
		return scrollSensitivity;
	}

	/**
	 * Sets the scroll sensitivity option value
	 * 
	 * @param scrollSensitivity
	 *            sortable scroll sensitivity
	 */
	public void setScrollSensitivity(int scrollSensitivity)
	{
		this.scrollSensitivity = scrollSensitivity;
		this.options.put("scrollSensitivity", "scrollSensitivity:" + scrollSensitivity);
	}

	/**
	 * Gets the containment value
	 * 
	 * @return the containment value
	 */
	public String getContainment()
	{
		return containment;
	}

	/**
	 * Sets the containment option value
	 * 
	 * @param containment
	 *            sortable containment
	 */
	public void setContainment(String containment)
	{
		this.containment = containment;
		this.options.put("containment", "containment:'" + containment + "'");
	}

	/**
	 * Gets the zIndex value
	 * 
	 * @return the zIndex value
	 */
	public int getZIndex()
	{
		return zIndex;
	}

	/**
	 * Sets the zIndex option value
	 * 
	 * @param index
	 *            sortable zIndex
	 */
	public void setZIndex(int index)
	{
		zIndex = index;
		this.options.put("zIndex", "zIndex:" + index);
	}

	/**
	 * Gets the cursor value
	 * 
	 * @return the cursor value
	 */
	public String getCursor()
	{
		return cursor;
	}

	/**
	 * Sets the cursor option value
	 * 
	 * @param cursor
	 *            sortable cursor
	 */
	public void setCursor(String cursor)
	{
		this.cursor = cursor;
		this.options.put("cursor", "cursor:'" + cursor + "'");
	}

	/**
	 * Gets the opacity value
	 * 
	 * @return the opacity value
	 */
	public float getOpacity()
	{
		return opacity;
	}

	/**
	 * Sets the opacity option value
	 * 
	 * @param opacity
	 *            sortable opacity
	 */
	public void setOpacity(float opacity)
	{
		this.opacity = opacity;
		this.options.put("opacity", "opacity:" + opacity);
	}

	/**
	 * Gets the place holder value
	 * 
	 * @return the place holder value
	 */
	public String getPlaceholder()
	{
		return placeholder;
	}

	/**
	 * Sets the place holder option value
	 * 
	 * @param placeholder
	 *            sortable placeHolder
	 */
	public void setPlaceholder(String placeholder)
	{
		this.placeholder = placeholder;
		this.options.put("placeholder", "placeholder:'" + placeholder + "'");
	}

	/**
	 * Gets the cancel value
	 * 
	 * @return the cancel value
	 */
	public String getCancel()
	{
		return cancel;
	}

	/**
	 * Sets the cancel option value
	 * 
	 * @param cancel
	 *            sortable cancel
	 */
	public void setCancel(String cancel)
	{
		this.cancel = cancel;
		this.options.put("cancel", "cancel:'" + cancel + "'");
	}

	/**
	 * Gets the tolerance value
	 * 
	 * @return the tolerance value
	 */
	public String getTolerance()
	{
		return tolerance;
	}

	/**
	 * Sets the tolerance option value
	 * 
	 * @param tolerance
	 *            sortable tolerance
	 */
	public void setTolerance(String tolerance)
	{
		this.tolerance = tolerance;
		this.options.put("tolerance", "tolerance:'" + tolerance + "'");
	}

	/**
	 * Gets the drop on empty value
	 * 
	 * @return the drop on empty value
	 */
	public boolean isDropOnEmpty()
	{
		return dropOnEmpty;
	}

	/**
	 * Sets the dropOnEmpty option value
	 * 
	 * @param dropOnEmpty
	 *            sortable dropOnEmpty
	 */
	public void setDropOnEmpty(boolean dropOnEmpty)
	{
		this.dropOnEmpty = dropOnEmpty;
		this.options.put("dropOnEmpty", "dropOnEmpty:" + dropOnEmpty);
	}

	/**
	 * Gets the force place holder size value
	 * 
	 * @return the force place holder size value
	 */
	public boolean isForcePlaceholderSize()
	{
		return forcePlaceholderSize;
	}

	/**
	 * Sets the forceplaceholderSize option value
	 * 
	 * @param forcePlaceholderSize
	 *            sortable force placeholder size
	 */
	public void setForcePlaceholderSize(boolean forcePlaceholderSize)
	{
		this.forcePlaceholderSize = forcePlaceholderSize;
		this.options.put("forcePlaceholderSize", "forcePlaceholderSize:" + forcePlaceholderSize);
	}

	/**
	 * Gets the delay value
	 * 
	 * @return the delay value
	 */
	public int getDelay()
	{
		return delay;
	}

	/**
	 * Sets the delay option value
	 * 
	 * @param delay
	 *            sortable delay
	 */
	public void setDelay(int delay)
	{
		this.delay = delay;
		this.options.put("delay", "delay:" + delay);
	}

	/**
	 * Gets the distance value
	 * 
	 * @return the distance value
	 */
	public int getDistance()
	{
		return distance;
	}

	/**
	 * Sets the distance option value
	 * 
	 * @param distance
	 *            sortable distance
	 */
	public void setDistance(int distance)
	{
		this.distance = distance;
		this.options.put("distance", "distance:" + distance);
	}

	/**
	 * Gets the start script value
	 * 
	 * @return the start function
	 */
	public String getStartScript()
	{
		return startScript;
	}

	/**
	 * Sets the start function
	 * 
	 * @param startScript
	 *            sortable start function
	 */
	public void setStartScript(String startScript)
	{
		this.startScript = startScript;
		this.options.put("start", "start:function(e, ui){" + startScript + "}");
	}

	/**
	 * Gets the stop script value
	 * 
	 * @return the stop function
	 */
	public String getStopScript()
	{
		return stopScript;
	}

	/**
	 * Sets the stop function
	 * 
	 * @param stopScript
	 *            sortable stop function
	 */
	public void setStopScript(String stopScript)
	{
		this.stopScript = stopScript;
		this.options.put("stop", "stop:function(e, ui){" + stopScript + "}");
	}

	/**
	 * Gets the update script value
	 * 
	 * @return the update function
	 */
	public String getUpdateScript()
	{
		return updateScript;
	}

	/**
	 * Sets the update function
	 * 
	 * @param updateScript
	 *            sortable update function
	 */
	public void setUpdateScript(String updateScript)
	{
		this.updateScript = updateScript;
		this.options.put("update", "update:function(e, ui){" + updateScript + "}");
	}

	/**
	 * Gets the sort script value
	 * 
	 * @return the sort function
	 */
	public String getSortScript()
	{
		return sortScript;
	}

	/**
	 * Sets the sort function
	 * 
	 * @param sortScript
	 *            sortable sort function
	 */
	public void setSortScript(String sortScript)
	{
		this.sortScript = sortScript;
		this.options.put("sort", "sort:function(e, ui){" + sortScript + "}");
	}

	/**
	 * Gets the change script value
	 * 
	 * @return the change function
	 */
	public String getChangeScript()
	{
		return changeScript;
	}

	/**
	 * Sets the change function
	 * 
	 * @param changeScript
	 *            sortable change function
	 */
	public void setChangeScript(String changeScript)
	{
		this.changeScript = changeScript;
		this.options.put("change", "change:function(e, ui){" + changeScript + "}");
	}

	/**
	 * Gets the beforeStop script value
	 * 
	 * @return the beforeStop function
	 */
	public String getBeforeStopScript()
	{
		return beforeStopScript;
	}

	/**
	 * Sets the beforeStop function
	 * 
	 * @param beforeStopScript
	 *            sortable beforeStop function
	 */
	public void setBeforeStopScript(String beforeStopScript)
	{
		this.beforeStopScript = beforeStopScript;
		this.options.put("beforeStop", "beforeStop:function(e, ui){" + beforeStopScript + "}");
	}

	/**
	 * Gets the receive script value
	 * 
	 * @return the receive function
	 */
	public String getReceiveScript()
	{
		return receiveScript;
	}

	/**
	 * Sets the receive function
	 * 
	 * @param receiveScript
	 *            sortable receive function
	 */
	public void setReceiveScript(String receiveScript)
	{
		this.receiveScript = receiveScript;
		this.options.put("receive", "receive:function(e, ui){" + receiveScript + "}");
	}

	/**
	 * Gets the remove script value
	 * 
	 * @return the remove function
	 */
	public String getRemoveScript()
	{
		return removeScript;
	}

	/**
	 * Sets the remove function
	 * 
	 * @param removeScript
	 *            sortable remove function
	 */
	public void setRemoveScript(String removeScript)
	{
		this.removeScript = removeScript;
		this.options.put("remove", "remove:function(e, ui){" + removeScript + "}");
	}

	/**
	 * Gets the over script value
	 * 
	 * @return the over function
	 */
	public String getOverScript()
	{
		return overScript;
	}

	/**
	 * Sets the over function
	 * 
	 * @param overScript
	 *            sortable over function
	 */
	public void setOverScript(String overScript)
	{
		this.overScript = overScript;
		this.options.put("over", "over:function(e, ui){" + overScript + "}");
	}

	/**
	 * Gets the out script value
	 * 
	 * @return the out function
	 */
	public String getOutScript()
	{
		return outScript;
	}

	/**
	 * Sets the out function
	 * 
	 * @param outScript
	 *            sortable out function
	 */
	public void setOutScript(String outScript)
	{
		this.outScript = outScript;
		this.options.put("out", "out:function(e, ui){" + outScript + "}");
	}

	/**
	 * Gets the activate script value
	 * 
	 * @return the activate function
	 */
	public String getActivateScript()
	{
		return activateScript;
	}

	/**
	 * Sets the activate function
	 * 
	 * @param activateScript
	 *            sortable activate function
	 */
	public void setActivateScript(String activateScript)
	{
		this.activateScript = activateScript;
		this.options.put("activate", "activate:function(e, ui){" + activateScript + "}");
	}

	/**
	 * Gets the deactivate script value
	 * 
	 * @return the deactivate function
	 */
	public String getDeactivateScript()
	{
		return deactivateScript;
	}

	/**
	 * Sets the deactivate function
	 * 
	 * @param deactivateScript
	 *            sortable deactivate function
	 */
	public void setDeactivateScript(String deactivateScript)
	{
		this.deactivateScript = deactivateScript;
		this.options.put("deactivate", "deactivate:function(e, ui){" + deactivateScript + "}");
	}
	
	@Override
	protected Object clone() throws CloneNotSupportedException
	{
		JQSortableOptions clone = (JQSortableOptions)super.clone();
		return clone;
	}
}
